﻿namespace ViewModel.Tests
{
    using NUnit.Framework;
    using NUnit.Framework.SyntaxHelpers;
    using Rhino.Mocks;

    [TestFixture]
    public class The_account_registration_form
    {
        private RegistrationController a_valid_controller;

        [SetUp]
        public void given_a_context_of()
        {
            var service = MockRepository.GenerateStub<IRegistrationService>();
            a_valid_controller = new RegistrationController(service);
            a_valid_controller.Email = "something";
            a_valid_controller.Password = "pw";
            a_valid_controller.Confirm = "pw";
        }

        [Test]
        public void is_invalid_when_the_email_address_is_blank()
        {
            a_valid_controller.Email = string.Empty;
            Assert.That(a_valid_controller.IsFormValid, Is.False);
        }

        [Test]
        public void is_valid_for_the_context()
        {
            Assert.That(a_valid_controller.IsFormValid, Is.True);
        }

        [Test]
        public void should_provide_an_error_when_the_email_address_is_blank()
        {
            a_valid_controller.Email = string.Empty;
            Assert.That(a_valid_controller.ValidationErrors, Has.Member("Email cannot be blank."));
        }
    }
}